<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/react.development.js" type="text/javascript"></script>
    <script src="../js/react-dom.development.js" type="text/javascript"></script>
    <script src="../js/babel.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="root"></div>
    <script type="text/babel">
        //组件不受React控制 
        class Login extends React.Component {
            handleSubmit = (event) => {
                event.preventDefault ? event.preventDefault() : event.returnValue = false;
                const { username, pwd } = this;
                console.log(`当前用户名：${username.value},密码：${pwd.value}`);
            }
            render() {
                return (
                    <form onSubmit={this.handleSubmit}>
                        <label htmlFor="username">用户名：</label>
                        <input type='text' ref={c => { this.username = c }} name="username" id="username" />
                        <label htmlFor="pwd">密码：</label>
                        <input type='password' ref={(c) => this.pwd = c} name="password" id="pwd" />
                        <button>提交</button>
                    </form>
                )
            }
        }
        ReactDOM.render(<Login />, document.getElementById('root'))
    </script>
</body>

</html>